// 相关协议地址
export const agreeOn = {
    userAgreement: 'https://help.bjca.cn/private/xssservice.html', // 用户服务协议
    digitalCertification: 'https://service.isignet.cn/private/eleservice.html', //电子认证服务协议
    CertificateOfCloud: 'https://service.isignet.cn/private/eleserviceCloud.html', //云证书电子认证服务协议
    personalInformation: 'https://service.isignet.cn/private/agreement.html', //个人信息保护政策
    RiskInformation: 'https://help.bjca.cn/private/risk-aware.html', //风险知情书
    personalFinance: 'https://service.isignet.cn/private/agreementAccount.html', //个人金融账户信息保护声明
    agreementBiometric: 'https://service.isignet.cn/private/agreementBiometric.html', //个人生物识别信息保护声明
}
// 计算时间差
export function dateDiff(dateBegin: number, dateEnd: number) {
    let dateDiff = dateEnd - dateBegin //时间差的毫秒数
    let value = dateDiff.toString().substring(0, dateDiff.toString().length - 3)
    value = value ? value : '0'
    return value
}

export function debounce(fn: any, wait: number) {
    let timer: any = null
    return function () {
        const context = this,
            args = arguments
        //如果此时存在定时器，取消掉之前的定时器重新计时
        if (timer) {
            clearTimeout(timer)
            timer = null
        }
        //设置定时器，使事件间隔指定事件后执行
        timer = setTimeout(() => {
            fn.apply(context, args)
        }, wait)
    }
}

//获取当前月份
const doHandleMonth = (month:any) => {
    let m = month
    if (month.toString().length == 1) {
        m = '0' + month
    }
    return m
}

export const getDay = (day: number) => {
    const today = new Date()
    const targetday_milliseconds = today.getTime() + 1000 * 60 * 60 * 24 * day
    today.setTime(targetday_milliseconds)
    const tYear = today.getFullYear()
    let tMonth = today.getMonth()
    let tDate = today.getDate()
    tMonth = doHandleMonth(tMonth + 1)
    tDate = doHandleMonth(tDate)
    return tYear + '-' + tMonth + '-' + tDate
}




export const tradeTypeMap:Record<string, string> = {
    '1': '企业证书制作',
    '2': '企业证书更新',
    '3': '企业证书补办',
    '5': '企业证书变更',
    '6': '企业证书吊销'
}

export const personTypeMap:Record<string, string> = {
    '1': '个人证书制作',
    '2': '个人证书更新',
    '3': '个人证书补办',
    '5': '个人证书变更',
    '6': '个人证书吊销'
}
